import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/less/index.less'

import router from './router/index'
import store from './store/index'

import http from 'axios'
import './api/mock.js'

Vue.config.productionTip = false
Vue.use(ElementUI)

Vue.prototype.$http = http

router.beforeEach((to,from,next) => {
    store.commit('getToken')
    const token = store.state.token.token
    if (!token && to.name !== 'login') {
        next({name:'login'})
    } else {
        next()
    }
})

new Vue({
    router,
    store,
    render: h => h(App),
}).$mount('#app')